package com.dkm.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.dkm.entity.Users;

public interface UsersRepository extends JpaRepository<Users, String>, JpaSpecificationExecutor<Users> {

	/**
	 * 根据登录名获取用户信息
	 * @param login_name
	 * @return
	 */
	@Query(value = "from Users where login_name=:login_name")
	Users findByLogin_name(@Param("login_name") String login_name);
	
	/**
	 * 根据部门id获取用户数量
	 * @param department_id 部门id
	 * @return 用户数量
	 */
	@Query(value = "select count(1) from users where department_id=:department_id",nativeQuery = true)
	Integer getUsersCountByDepartment_id(@Param("department_id") String department_id);
}
